//API进行统一管理
import requests from "@/api/request";
import mockAjax from './ajaxMock'
import * as url from "url";

//三级联动接口(get请求，无参数) 地址：/api/product/getBaseCategoryList
export const reqCategoryList=()=>{
    //发请求,返回结构是promise对象
   return  requests({url:'/product/getBaseCategoryList', method:'get'})
}
// 获取广告轮播列表
export const reqBanners = ()=> mockAjax.get('/banners')
// 获取首页楼层列表
export const reqFloors = ()=> mockAjax.get('/floors')
//搜索模块接口,需要带参数，post请求，地址：/api/list
//传递参数，至少是一个空对象
export const reqGetSearchInfo=(params)=>requests({url:'/list',method:'post',data:params})
//商品详情模块,get方式，需要带参数，地址：/api/item/{ skuId }
export const reqGoodsInfo=(skuId)=>requests({url:`/item/${skuId }`,method:'get'})
//添加至购物车中或者更新产品的数量,地址/api/cart/addToCart/{ skuId }/{ skuNum }，post请求，需要带参数
export const reqAddOrUpdateShopCart=(skuId,skuNum)=>requests({url:`/cart/addToCart/${skuId}/${skuNum}`,method:'post'})
//获取购物车列表，地址/api/cart/cartList，get方式
export const reqShopCart=()=>requests({url:'/cart/cartList',method:'get'})
//删除购物车，地址/api/cart/deleteCart/{skuId}，delete方式
export const reqDeleteCartById=(skuId)=>requests({url:`/cart/deleteCart/${skuId}`,method:'delete'})
//修改商品的选中状态,地址/api/cart/checkCart/{skuID}/{isChecked}，get请求
export const reqUpdateCheckedById=(skuId,isChecked)=>requests(({url:`/cart/checkCart/${skuId}/${isChecked}`,method:'get'}))
//获取验证码接口，地址/api/user/passport/sendCode/{phone}，get方式
export const reqGetCode=(phone)=>requests({url:`/user/passport/sendCode/${phone}`,method:'get'})
//注册用户接口，地址/api/user/passport/register，post请求 参数：phone，code，password
export const reqUserRegister=(data)=>requests({url:'/user/passport/register',method:'post',data})
//登录用户接口，地址/api/user/passport/login，post请求，参数phone，password
export const reqUserLogin=(data)=>requests({url:'/user/passport/login',data,method:'post'})
//获取用户信息，需要带token向服务器要用户信息,地址/api/user/passport/auth/getUserInfo，get请求
export const reqUserInfo=()=>requests({url:'/user/passport/auth/getUserInfo',method:'get'})
//退出登录，地址/api/user/passport/logout，get请求
export const reqLogout=()=>requests({url:'/user/passport/logout',method:'get'})
//获取用户地址的信息，地址/api/user/userAddress/auth/findUserAddressList，get请求
export const reqAddressInfo=()=>requests({url:'/user/userAddress/auth/findUserAddressList',method:'get'})
//获取用户订单，地址/api/order/auth/trade，get请求
export const reqOrderInfo=()=>requests({url:'/order/auth/trade',method:'get'})
//提交订单，地址/api/order/auth/submitOrder?tradeNo={tradeNo}，post方式
export const reqSubmitOrder=(tradeNo,data)=>requests({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,method:'post',data})
//获取支付信息，地址/api/payment/weixin/createNative/{orderId}，get方式
export const reqPay=(orderId)=>requests({url:`/payment/weixin/createNative/${orderId}`,method:'get'})
//获取支付订单状态,地址/api/payment/weixin/queryPayStatus/{orderId}，get方式
export const reqPayState=(orderId)=>requests({url:`/payment/weixin/queryPayStatus/${orderId}`,method:'get'})
//获取个人中心数据，地址：/api/order/auth/{page}/{limit}，get方式
export const reqGetMyOrderList=(page,limit)=>requests({url:`/order/auth/${page}/${limit}`,method:'get'})